$(function(){
	//发帖
	$("*[id^='newpost-']").each(function(){
		$(this).click(function(){
			showLayer('发帖',$("#create-new-post-layer"));
		})
	});
	
	$("#post-creat-btn").click(function() {
		
		window.location.reload();
	});
	
	
});

var contentListener = function(){
	var replyBlock = $("#editor-task p");
	replyBlock.bind('DOMNodeInserted',function(e){
		if($(e.target).text() != null){
			$(".reply-btn-bar").show();
		}else {
			$(".reply-btn-bar").hide();
		}
		
	});
}

var showLayer = function(name, layerContent){
	var index = layer.open({
		type:1,
		title: ''+name+'',
		fixed: false, //不固定
		maxmin: true,
		closeBtn: 1,
		scrollbar: false,
		area: 'auto',
		content: layerContent
	});
	layer.full(index);
}

var init = function() {
	var editorTask = new wangEditor('editor-task');
	editorTask.config.menus = [
	    /*'fullscreen',*/
	    ' | ',
		'bold',
		'underline',
		'italic',
		'strikethrough',
		'eraser',
		'forecolor',
		'bgcolor',
		'quote',
		'fontfamily',
		'fontsize',
		'head',
		'unorderlist',
		'orderlist',
		'alignleft',
		'aligncenter',
		'alignright',
		'link',
		'unlink',
		'table',
		'emotion',
		'img',
		'video',
		'insertcode',
		'undo',
		'redo'
    ];
	
	/*editorTask.config.uploadImgUrl = CONTEXT_PATH + 'resource/editUpload';
	editorTask.config.uploadImgFileName='editor-task';
	editorTask.config.zindex = 20000;*/
	editorTask.create();
}

var initAnswer = function() {
	var editorTask = new wangEditor('editor-answer');
	editorTask.config.menus = [
	    'fullscreen',
	    ' | ',
		'bold',
		'underline',
		'italic',
		'strikethrough',
		'eraser',
		'forecolor',
		'bgcolor',
		'quote',
		'fontfamily',
		'fontsize',
		'head',
		'unorderlist',
		'orderlist',
		'alignleft',
		'aligncenter',
		'alignright',
		'link',
		'unlink',
		'table',
		'emotion',
		'img',
		'video',
		'insertcode',
		'undo',
		'redo'
    ];
	
	/*editorTask.config.uploadImgUrl = CONTEXT_PATH + 'resource/editUpload';
	editorTask.config.uploadImgFileName='editor-answer';
	editorTask.config.zindex = 20000;*/
	editorTask.create();
}